package yev.testdb.tutorial;
import org.springframework.orm.jpa.support.JpaDaoSupport;


public interface EmployeeDAO extends JpaDaoSupport implements  EmployeeService {
	
	public Employee findById(long id) {
	      return getJpaTemplate().find(Employee.class, id);
	   }
	    public List<Employee> findAll() {
	       return getJpaTemplate().find("select e from Employee e");
	    }
	   public List<Employee> findByEmployeeNumber(String empno) {
	      return getJpaTemplate().find(
	      "select e from Employee e where e.empno = ?1", empno);
	   }

	   public List<Employee> findByAddressStreetName(String street) {
	      return getJpaTemplate().find(
	      "select e from Employee e where e.addr.street = ?1", street);
	   }

	   public List<Employee> findByEmployeeLastName(String lastName) {
	      return getJpaTemplate().find(
	      "select e from Employee e where e.lastName = ?1", lastName);
	   }

	   public List<Employee> findEmployeeWithSalaryOver(double sal) {
	      return getJpaTemplate().find(
	      "select e from Employee e where e.salary > ?1", sal);
	   }

	   public List<Employee> findEmployeeWithCommissionOver(double comm) {
	      return getJpaTemplate().find(
	      "select e from Employee e where e.commission > ?1", comm);
	   }

	   public Employee save(Employee emp) {

	      getJpaTemplate().persist(emp);
	      return emp;
	   }

	   public Employee update(Employee emp) {
	      return getJpaTemplate().merge(emp);
	   }

	   public void delete(Employee emp) {
	      getJpaTemplate().remove(emp);
	         
	   }


}
